using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace vengeful_bean
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class LevelManager 
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        MapManager map;
        EventManager eventManager;
        CharacterManager characterManager;

        StringBuilder sb = new StringBuilder();

        GAMESTATE gameState;
        public LEVEL gameLevel;
        ContentManager Content;
        




        /// <summary>
        /// initilize the Level manager to that level
        /// </summary>
        /// <param name="graphics">graphics device controller</param>
        /// <param name="Content">content manager</param>
        /// <param name="level">which level of the game</param>
        public LevelManager(GraphicsDeviceManager graphics, ContentManager Content, LEVEL level)
        {
            // TODO: Complete member initialization
            this.graphics = graphics;
            this.Content = Content;
            this.gameLevel = level;

            // TODO: Construct any child components here
            sb.Clear();
            sb.Append(gameLevel.ToString());

            this.InitilizeManagers(sb.ToString());
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public void Initialize()
        {
            // TODO: Add your initialization code here

            
        }

        /// <summary>
        /// Load all content related to this level
        /// </summary>
        public void LoadContent()
        {
           

            

            ///LOAD ALL CONTECT RELATED TO THE LEVEL HERE
            ///
            //map.LoadContent(spriteBatch);
            //characterManager.LoadContent(spriteBatch);

           
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            map.Update(gameTime);
            eventManager.Update(gameTime);
            characterManager.Update(gameTime);

        }


        /// <summary>
        /// Draw
        /// </summary>
        /// <param name="gameTime"></param>
        public void Draw( SpriteBatch spriteBatch, GameTime gameTime)
        {


            map.Draw(spriteBatch, gameTime);
            characterManager.Draw(spriteBatch, gameTime);
        }


        protected void InitilizeManagers(string mLevel)
        {
            map = new MapManager(graphics, Content, mLevel);
            eventManager = new EventManager(graphics, Content, mLevel);
            //unslash when completed (should be a vector of characters)
            //characterManager.NPC = eventManager.NPC;

        }


    }
}
